

/**
 * 作者：I-AM-WASTE
 * TIME:2022年10月4日
 */

let p = new Vue({
    el:"#gameShow",
    data:{
        gameShow:[],
        pageNum:1,
        newTitle:'',
        bcTitle:'',
        wantUp:{
            gameName: '',
            email: ''
        },
        showBox:false
    },
    // created:function (){
    //     axios.post("/showsrc/"+this.title+"/"+this.pageNum).then(function (response){
    //         p.gameShow = response.data
    //     })
    //
    // },
    methods:{
        srcUp(){
            if (this.newTitle.length > 0 && this.newTitle.trim().length !== 0){
                axios.post("/search/"+this.newTitle+"/"+this.pageNum).then(function (response){
                    p.gameShow = response.data
                    p.newTitle = ''
                    document.documentElement.scrollTop = document.getElementById("gamesrcdw").offsetTop;
                })
            }else {
                this.$Message.warning({
                    content: "提交的搜索信息不能为空噢(✿◡‿◡)",
                    duration: 5
                });
            }
        },
        page(index){
            axios.post("/search/"+this.newTitle+"/"+index).then(function (response){
                p.gameShow = response.data
                document.documentElement.scrollTop = document.getElementById("gamesrcdw").offsetTop;
            })
        },
        yiru(index){
            this.$refs.imgshow[index].style.boxShadow = "0  45px 45px  -35px rgba(0,0,0,0.9)"
            this.$refs.pact[index].style.color = "#e72727"
            this.$refs.masact[index].style.bottom = "-30px"
        },
        yichu(index){
            this.$refs.imgshow[index].style.boxShadow = ""
            this.$refs.pact[index].style.color = ""
            this.$refs.masact[index].style.bottom = ""
        },
        //内容搜索
        want(){
            if (p.wantUp.gameName !== '' && p.wantUp.email !== ''){
                if (p.wantUp.gameName.length > 0 && p.wantUp.gameName.trim().length !== 0 && p.wantUp.email.length > 0 && p.wantUp.email.trim().length !== 0) {
                    axios.post("/search/gamewant", p.wantUp).then(function (response) {
                        p.wantUp.gameName = '';
                        p.wantUp.email = ''
                        this.showBox =!this.showBox
                    })
                    this.$Message.success({
                        content: "芜湖！提交成功φ(*￣0￣)",
                        duration: 5
                    });
                }else {
                    this.$Message.warning({
                        content: "提交的信息不能为空格噢(✿◡‿◡)",
                        duration: 5
                    });
                }
            }else {
                this.$Message.warning({
                    content: "提交的信息不能为空噢(✿◡‿◡)",
                    duration: 5
                });
            }
        },
        wxandqq(index){
            let host = window.location.host
            let title = document.getElementById("name"+index).innerText
            let url = "【暮迟的游戏小屋】  "+title+"  "+"http://"+host+"/gameart/"+index;
            this.copyToClipboard(url)
            p.$Message.success({
                content: "复制成功！快去粘贴吧！",
                duration: 3
            });
        },
        // 点击复制到剪贴板函数
        copyToClipboard(content) {
            if (window.clipboardData) {
                window.clipboardData.setData('text', content);
            } else {
                (function (content) {
                    document.oncopy = function (e) {
                        e.clipboardData.setData('text', content);
                        e.preventDefault();
                        document.oncopy = null;
                    }
                })(content);
                document.execCommand('copy');
            }
        },
    }
})

